package File;

import IO.Buffered;

import java.io.*;
import java.util.Properties;

/**
 * @author wuhan
 * @date 2019/10/12 10:57
 */
public class PropertiesDemo {


    public static void main(String[] args) throws IOException {
        int count;
        Properties properties=new Properties();
//        properties.setProperty("name","wuhan");
//        properties.setProperty("sex","male");
//        BufferedWriter bufferedWriter=new BufferedWriter(new FileWriter("pro.properties"));
//        properties.store(bufferedWriter,"a.tat");
        BufferedReader bufferedReader=new BufferedReader(new FileReader("pro.properties"));
        properties.load(bufferedReader);
//        System.out.println(properties.getProperty("name"));
//        System.out.println(properties);
         count= Integer.parseInt(properties.getProperty("count"));
        System.out.println("这是第"+count+"次打开此程序");
        count++;
        properties.setProperty("count", String.valueOf(count));
        BufferedWriter bufferedWriter=new BufferedWriter(new FileWriter("pro.properties"));
        properties.store(bufferedWriter,"");
        bufferedReader.close();
        bufferedWriter.close();

    }
}
